/******************************************************************************
** 
** Power "n" of a number "m";
** 
** File name:	power.c
** Compilation:	cc power.c -o power
** Execution:	./power
** 
** Description:
** Introducing functions. Example of a function with two agruments: base and
** power, the result is the number of multiplication.
** 
******************************************************************************/
#include <stdio.h>

int power(int base, int n); // function prototype
int i;

int main()
{
    for (i=1; i<=10; ++i) {
      printf("%d\t%d\t%d\n", i, power(2, i), power(-3, i));
    }
    return 0;
}


// power: returns the "base" in "n"-th power (n>=0)
int power(int base, int n) {
    int p;
    
    p = 1;
    for (p=1; n>0; --n) {
      p = base*p;
    }
    return p;
}